package dk.ucn.datamatiker.henrik.bundtkage.earthcake.albeheweather;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class Connection {
	private static Connection instance;

	public Connection() {

	}

	public static Connection getInstance() {
		if (instance == null) {
			instance = new Connection();
		}
		return instance;
	}

	public void getConnection(Context context) {
		boolean networkAvailable = checkNetwork(context);
		if (networkAvailable) {
			// Get the connection
		} else {
			// connection = null
		}
	}

	public boolean checkNetwork(Context context) {
		ConnectivityManager connectivityManager = (ConnectivityManager) context
				.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
		if (networkInfo.isConnected()) {
			return true;
		} else {
			return false;
		}
	}
}
